﻿using DataLayer.Entities;
using DataLayer.Implementations;
using DataLayer.Interfaces;
//using SecurityGuard.Interfaces;
//using SecurityGuard.Services;
using SecurityGuard.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;

namespace CakeManagementSystemFoundation.Controllers
{
    public class LoginController : Controller
    {
        #region Constructors

        //private IMembershipService membershipService;
        //private IAuthenticationService authenticationService;
        //private IFormsAuthenticationService formsAuthenticationService;

        //public LoginController()
        //{
        //    this.membershipService = new MembershipService(Membership.Provider);
        //    this.authenticationService = new AuthenticationService(membershipService, new FormsAuthenticationService());
        //    this.formsAuthenticationService = new FormsAuthenticationService();
        //}

        #endregion
        public ActionResult Index()
        {
            INHibernateModel model = new NHibernateModel();
            IList<Evento> roles = model.GetAll<Evento>();
            return View();
        }

        [HttpPost]
        public ActionResult Login(LogOnViewModel model, string returnUrl)
        {
            //if (ModelState.IsValid)
            //{
            //    if (authenticationService.LogOn(model.UserName, model.Password, model.RememberMe))
            //    {
            //        if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/")
            //            && !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
            //        {
            //            return Redirect(returnUrl);
            //        }
            //        else
            //        {
            //            return RedirectToAction("Index", "Home");
            //        }
            //    }
            //    else
            //    {
            //        MembershipUser user = membershipService.GetUser(model.UserName);
            //        if (user == null)
            //        {
            //            ModelState.AddModelError("", "This account does not exist. Please try again.");
            //        }
            //        else
            //        {
            //            if (!user.IsApproved)
            //            {
            //                ModelState.AddModelError("", "Your account has not been approved yet.");
            //            }
            //            else if (user.IsLockedOut)
            //            {
            //                ModelState.AddModelError("", "Your account is currently locked.");
            //            }
            //            else
            //            {
            //                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            //            }
            //        }
            //    }
            //}

            //// If we got this far, something failed, redisplay form
            //return RedirectToAction("Login");
            return null;
        }
    }
}
